
/*
  参数说明：
  {
    path: '/home', // 路由的访问路径
    name: 'Home', // 路由名称, 必须设置,且不能重名
    component: "", // 控制路由和子路由是否显示
    hidden: true, // 重定向地址, 访问这个路由时,自定进行重定向
    redirect: '', // 路由在menu上显示的图标
    icon: 'a-icon', // 菜单图标，没有图标设置为空
    children: [], // 子级菜单 
    meta: {
      title: '首页',  // 路由标题
      keepAlive: false, // 缓存该路由
      permission: [] // 权限拦截匹配
    }
  }
*/
// 侧边栏数据
export const allMenus = [
	{
		path: "/home",
		name: "Home",
		component: '/examples/DemoOne.vue',
		hidden: true,
		meta: { title: "门户首页" },
		redirect: "",
		children: [],
	},
	{
		path: "/user-manage",
		name: "UserManage",
		component: '/examples/DemoOne.vue',
		icon: 'dashboard',
		hidden: false,
		meta: { title: "用户管理" },
		redirect: "",
		children: [
			{
				path: "/user-manage/custom-search",
				name: "CustomSearch1",
				component: '/examples/DemoOne.vue',
				icon: 'dashboard',
				hidden: false,
				meta: { title: "客户信息查询" },
				redirect: "",
				children: [],
			},
			{
				path: "/user-manage/debt-search",
				name: "DebtSearch1",
				component: '/examples/DemoOne.vue',
				icon: 'dashboard',
				hidden: false,
				meta: { title: "债项信息查询" },
				redirect: "",
				children: [],
			},
			{
				path: "/user-manage/user-manage-demo-one",
				name: "userManageDemoOne",
				component: '/examples/DemoOne.vue',
				icon: 'dashboard',
				hidden: false,
				meta: { title: "用户管理子级1" },
				redirect: "",
				children: [],
			},
			{
				path: "/user-manage/user-manage-demo-two",
				name: "userManageDemoTwo",
				component: '/examples/DemoOne.vue',
				icon: 'dashboard',
				hidden: false,
				meta: { title: "用户管理子级2" },
				redirect: "",
				children: [],
			},
			{
				path: "/user-manage/user-manage-demo-thr",
				name: "userManageDemoThr",
				component: '/examples/DemoOne.vue',
				icon: 'dashboard',
				hidden: false,
				meta: { title: "用户管理子级3" },
				redirect: "",
				children: [],
			},
			{
				path: "/user-manage/user-manage-demo-four",
				name: "userManageDemoFour",
				component: '/examples/DemoOne.vue',
				icon: 'dashboard',
				hidden: false,
				meta: { title: "用户管理子级4" },
				redirect: "",
				children: [],
			},
			{
				path: "/user-manage/user-manage-demo-five",
				name: "userManageDemoFive",
				component: '/examples/DemoOne.vue',
				icon: 'dashboard',
				hidden: false,
				meta: { title: "用户管理子级5" },
				redirect: "",
				children: [],
			},
			{
				path: "/user-manage/user-manage-demo-six",
				name: "userManageDemoSix",
				component: '/examples/DemoOne.vue',
				icon: 'dashboard',
				hidden: false,
				meta: { title: "用户管理子级6" },
				redirect: "",
				children: [],
			},
			
		],
	},
	{
		path: "/role-manage",
		name: "RoleManage",
		component: '/examples/DemoOne.vue',
		icon: 'dashboard',
		hidden: false,
		meta: { title: "角色管理" },
		redirect: "",
		children: [],
	},
	{
		path: "/menu-manage",
		name: "MenuManage",
		component: '/examples/DemoOne.vue',
		icon: 'dashboard',
		hidden: false,
		meta: { title: "菜单管理" },
		redirect: "",
		children: [],
	},
	{
		path: "/search",
		name: "Search",
		component: 'BlankView',
		icon: 'dashboard',
		hidden: false,
		meta: { title: "信息查询" },
		redirect: "",
		children: [
			{
				path: "/search/custom-search",
				name: "CustomSearch",
				component: '/examples/DemoOne.vue',
				icon: 'dashboard',
				hidden: false,
				meta: { title: "客户信息查询" },
				redirect: "",
				children: [
					{
						path: "/search/custom-search/demo1",
						name: "CustomSearchDemo1",
						component: '/examples/DemoOne.vue',
						icon: 'dashboard',
						hidden: false,
						meta: { title: "客户信息查询1" },
						redirect: "",
						children: [],
					},
				],
			},
			{
				path: "/search/debt-search",
				name: "DebtSearch",
				component: '/examples/DemoOne.vue',
				icon: 'dashboard',
				hidden: false,
				meta: { title: "债项信息查询" },
				redirect: "",
				children: [],
			},
			{
				path: "/search/custom-info-search",
				name: "CustomInfoSearch",
				component: '/examples/DemoOne.vue',
				icon: 'dashboard',
				hidden: false,
				meta: { title: "客户信息查询明细" },
				redirect: "",
				children: [],
			},
			{
				path: "/search/debt-info-search",
				name: "DebtInfoSearch",
				component: '/examples/DemoOne.vue',
				icon: 'dashboard',
				hidden: false,
				meta: { title: "债项信息查询明细" },
				redirect: "",
				children: [],
			},
		],
	}
]

// 菜单表格数据
export const menuTreeData = function () {
	let resultList = []
	let results = getMenuTreeData(allMenus, 1);
	resultList = getMenuListData(results, null, resultList)
	return resultList
}

function getMenuTreeData(menus, level) { 
	for (let index in menus) {
		let menuItem = menus[index]
		menuItem['id'] = (index + 1) * level
		menuItem['title'] = menuItem.meta.title
		if (menuItem.children.length > 0) {
			menuItem.children = getMenuTreeData(menuItem.children, level + 1)
		}
	}
	return menus
}

function getMenuListData(menus, parentId, list) {
	for (let menuItem of menus) {
		menuItem['parentId'] = parentId
		list.push(menuItem)
		if (menuItem.children.length > 0) {
			menuItem.children = getMenuListData(menuItem.children, menuItem.id, list)
		}
		delete menuItem.children
	}
	return list
}
